package com.sctvcloud.bazhong.ui.utils;

import android.support.annotation.CallSuper;

import com.shuyu.gsyvideoplayer.listener.StandardVideoAllCallBack;
import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack;

/**
 * Created by liuyu on 2017/9/18.
 */

public abstract class SampleListener implements StandardVideoAllCallBack {

    public static final int STATE_PREPARED = 101;
    public static final int STATE_IDEL = 107;

    protected int state;

    protected boolean isLiving;

    protected SampleListener internal;

    protected boolean isPlayed;

    @CallSuper
    @Override
    public void onPrepared(String url, Object... objects) {
        state = STATE_PREPARED;
        isPlayed = true;
        if (internal != null) {
            internal.onPrepared(url, objects);
        }
    }

    @Override
    public void onClickStartIcon(String url, Object... objects) {
    }

    @Override
    public void onClickStartError(String url, Object... objects) {
    }

    @CallSuper
    @Override
    public void onClickStop(String url, Object... objects) {
        state = STATE_IDEL;
    }

    @Override
    public void onClickStopFullscreen(String url, Object... objects) {
    }

    @Override
    public void onClickResume(String url, Object... objects) {
    }

    @Override
    public void onClickResumeFullscreen(String url, Object... objects) {
    }

    @Override
    public void onClickSeekbar(String url, Object... objects) {
    }

    @Override
    public void onClickSeekbarFullscreen(String url, Object... objects) {
    }

    @CallSuper
    @Override
    public void onAutoComplete(String url, Object... objects) {
        state = STATE_IDEL;
    }

    @CallSuper
    @Override
    public void onEnterFullscreen(String url, Object... objects) {
        if (internal != null) {
            internal.onEnterFullscreen(url, objects);
        }
    }

    @CallSuper
    @Override
    public void onQuitFullscreen(String url, Object... objects) {
        if (internal != null) {
            internal.onQuitFullscreen(url, objects);
        }
    }

    @Override
    public void onQuitSmallWidget(String url, Object... objects) {
    }

    @Override
    public void onEnterSmallWidget(String url, Object... objects) {
    }

    @Override
    public void onTouchScreenSeekVolume(String url, Object... objects) {
    }

    @Override
    public void onTouchScreenSeekPosition(String url, Object... objects) {
    }

    @Override
    public void onTouchScreenSeekLight(String url, Object... objects) {
    }

    @CallSuper
    @Override
    public void onPlayError(String url, Object... objects) {
        state = STATE_IDEL;
    }

    @Override
    public void onClickStartThumb(String url, Object... objects) {
    }

    @Override
    public void onClickBlank(String url, Object... objects) {
    }

    @Override
    public void onClickBlankFullscreen(String url, Object... objects) {
    }

    public void onPlayerHiddened(){
        if (internal!=null){
            internal.onPlayerHiddened();
        }
    }

    public boolean isInVideo() {
        return state >= STATE_PREPARED && state < STATE_IDEL;
    }

    public int getState() {
        return state;
    }

    public void setInternal(SampleListener internal) {
        this.internal = internal;
    }

    public void setLiving(boolean living) {
        isLiving = living;
    }

    public boolean isPlayed() {
        return isPlayed;
    }
}
